<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<%-- <%@ taglib prefix="c"      uri="http://java.sun.com/jsp/jstl/core" %> --%>
<%-- <%@ taglib prefix="fmt"    uri="http://java.sun.com/jsp/jstl/fmt" %> --%>
<%-- <%@ taglib prefix="fn"     uri="http://java.sun.com/jsp/jstl/functions" %> --%>
<%@ page import="com.ex.fileupdown.util.EgovDateUtil" %>

<script type="text/javascript" src="/resources/js/com.js"></script>
<script type="text/javascript" src="/resources/js/jquery-1.7.1.js"></script> 						<!-- jquery 1.9.1 -->
<script type="text/javascript" src="/resources/js/ajaxPagingList.js"></script> 						
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />	<!-- tooltip에 대한 jquery -->
<link rel="stylesheet" href="/resources/css/bootstrap.min.css" />									<!-- bootstrap에 대한 css -->
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>										<!-- 달력에 대한 jquery -->
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> 								<!-- datepicker에 대한 jquery -->
<script type="text/javascript" src="/resource/js/bootstrap.min.js"></script> 						<!-- bootstrap 대한 jquery -->

<jsp:scriptlet>
pageContext.setAttribute("crlf", "\r\n");
pageContext.setAttribute("lf", "\n");
pageContext.setAttribute("cr", "\r");
</jsp:scriptlet>
<%  
    String str_currentDate =EgovDateUtil.getCurrentDateTime("");
// SSO_ID
	String SSO_ID = (String)session.getAttribute("SSO_ID");
	if(SSO_ID == null || SSO_ID.equals("") ){
		SSO_ID = "20512518";
	}
%>
<script type="text/javascript" src="<c:url value="/resources/js/common.js"/>"></script>
<script type="text/javascript" src="<c:url value="/resources/js/json2.js" /> "></script>
<script type ="text/javascript">
var relativeUrl = "${pageContext.request.contextPath}";

function fnc_setPaging(totalRow,maxRow,curPage){
    if(totalRow=="" || totalRow==0){
        $('div.pg1').html('');
        return;
    }
    var currentPage = parseInt(curPage);
    var pages     = 10; //하단에 나오는 번호들의 갯수
    var curPageList = Math.floor((currentPage-1)/pages+1); //현재 하단 번호들 집합들의 순번 (ex:1,2,3,4,5 는 1 6,7,8,9,10은 2)
    var pageLists = Math.ceil(totalRow /( pages * maxRow)); //총 page 번호 갯수
    var lastPages = Math.ceil(totalRow / maxRow );       //마지막 page 번호

    var innerStr = "<table border=0 align='center'><tr>";

    if(currentPage > 1 && currentPage < pages ){ //현재 page가 1에서 pages 사이인 경우
        innerStr += "<td align='left' width='20'><span class='searchPage' id='prev'  style='cursor:pointer'><img src='/resources/images/home/recruit/c_icon05.gif' border='0' alt=''></span></td>";
    }else if(currentPage >= pages){
        innerStr += "<td align='left' width='20'><span class='searchPage' id='first' style='cursor:pointer'><img src='/resources/images/home/recruit/c_icon04.gif' border='0' alt=''></span></td>";
        innerStr += "<td align='left' width='20'><span class='searchPage' id='prev'  style='cursor:pointer'><img src='/resources/images/home/recruit/c_icon05.gif' border='0' alt=''></span></td>";
    }

    for( var i = (curPageList-1)*pages+1 ; i <= (curPageList-1)*pages+pages ; i++){
        if (i == currentPage) {
            innerStr += "<td style='text-align:center'><strong>" + i + "</strong></td>";
        } else {
            innerStr += "<td style='text-align:center'><span class='searchPage'><a class='num'>"+i+"</a></span></td>";
        }

        if(pageLists == curPageList && lastPages == i){
            break;
        }
    }

    if(currentPage != lastPages && currentPage + pages > lastPages ){
        innerStr += "<td align='right' width='20'><span class='searchPage' id='next' style='cursor:pointer'><img src='/resources/images/home/recruit/c_icon06.gif' border='0' alt=''></span></td>";
    }else if(currentPage + pages <= lastPages){
        innerStr += "<td align='right' width='20'><span class='searchPage' id='next' style='cursor:pointer'><img src='/resources/images/home/recruit/c_icon06.gif' border='0' alt=''></span></td>";
        innerStr += "<td align='right' width='20'><span class='searchPage' id='end'  style='cursor:pointer'><img src='/resources/images/home/recruit/c_icon07.gif' border='0' alt=''></span></td>";
    }

    innerStr += "</tr></table>";

    $('div.pg1').html(innerStr);
}

function fnc_setComboBoxList(text,selectBoxName,grpCd,cdNo,pGrpCd,pCdCd,allYn,option,url){

    var innerStr = null;
    var divName = "div."+selectBoxName;

    $(divName).html('');

    innerStr = "<table border=0 align='left'><tr><td>"+text+"<select id='"+selectBoxName+"' name='"+selectBoxName+"' "+option+"></select></td></tr></table>";
    $(divName).html(innerStr);

    if(selectBoxName == ""){
        $(divName).html('');
        return;
    }
    fnc_setComboBoxOption(text,selectBoxName,grpCd,cdNo,pGrpCd,pCdCd,allYn,url);
}


function fnc_setComboBoxOption(text,selectBoxName,grpCd,cdNo,pGrpCd,pCdCd,allYn,url){
    var tmpData = "data."+selectBoxName;

    //ComboBox Option 초기화
    $("select[name="+selectBoxName+"]").find("option").remove();

    $.ajax({
        type : "POST",
        url : url,
        dataType : "json",
        async: false,
        data :
        {listName : selectBoxName,
         grpCd  : grpCd,
         cdNo   : cdNo,
         pGrpCd : pGrpCd,
         pCdCd  : pCdCd,
         allYn  : allYn
        },
        success : function(data) {
            $(eval(tmpData)).each(function(index) {
                $("select[name="+selectBoxName+"]").append(
                        "<option value=\""+eval(tmpData)[index].grpCd+"_"+eval(tmpData)[index].cdNo+"\">"+eval(tmpData)[index].cdNm+"</option>"
                );
            });
        },

        error : function(XMLHttpRequest, textStatus, errorThrown) {
              alert("error:"+textStatus+"errorThrown :"+errorThrown);
             }
        });
}

function fnc_setComboBoxCallBackOptionWithValue(text,selectBoxName,grpCd,cdNo,pGrpCd,pCdCd,allYn,url,value){

    var tmpData = "data."+selectBoxName;

    //ComboBox Option 초기화
    $("select[id="+selectBoxName+"]").find("option").remove();

    $.ajax({
        type : "POST",
        url : url,
        dataType : "json",
        async: false,
        data :
        {listName : selectBoxName,
         grpCd  : grpCd,
         cdNo   : cdNo,
         pGrpCd : pGrpCd,
         pCdCd  : pCdCd,
         allYn  : allYn
        },
        success : function(data) {
            $(eval(tmpData)).each(function(index) {
                $("select[id="+selectBoxName+"]").append(
                        "<option value=\""+eval(tmpData)[index].grpCd+"_"+eval(tmpData)[index].cdNo+"\">"+eval(tmpData)[index].cdNm+"</option>"
                );
            });

            if(value!=""){
                $("#"+selectBoxName+" > option[value ="+value+"]").attr("selected","true");
            }
        },

        error : function(XMLHttpRequest, textStatus, errorThrown) {
              alert("error:"+textStatus+"errorThrown :"+errorThrown);
             }
        });
}

function fnc_setComboBoxCallBackOption(text,selectBoxName,grpCd,cdNo,pGrpCd,pCdCd,allYn,url,valId){

    var tmpData = "data."+selectBoxName;

    //ComboBox Option 초기화
    $("select[id="+selectBoxName+"]").find("option").remove();

    $.ajax({
        type : "POST",
        url : url,
        dataType : "json",
        async : false,
        data :
        {listName : selectBoxName,
         grpCd  : grpCd,
         cdNo   : cdNo,
         pGrpCd : pGrpCd,
         pCdCd  : pCdCd,
         allYn  : allYn
        },
        success : function(data) {
            $(eval(tmpData)).each(function(index) {
                $("select[id="+selectBoxName+"]").append(
                        "<option value=\""+eval(tmpData)[index].grpCd+"_"+eval(tmpData)[index].cdNo+"\">"+eval(tmpData)[index].cdNm+"</option>"
                );
            });

            $("#"+selectBoxName+" > option[value ="+grpCd+"_"+$("#"+valId).val()+"]").attr("selected","true");
        },

        error : function(XMLHttpRequest, textStatus, errorThrown) {
              alert("error:"+textStatus+"errorThrown :"+errorThrown);
             }
        });
}

function fnc_setCodeComboBoxOption(text, selectBoxName, grpCd, allYn, value){

    var tmpData = "data."+selectBoxName;

    //ComboBox Option 초기화
    $("select[name="+selectBoxName+"]").find("option").remove();

    $.ajax({
        type : "POST",
        url : relativeUrl+"/common/commonCode",
        dataType : "json",
        async : false,
        data :
        {listName : selectBoxName,
         grpCd  : grpCd,
         allYn  : allYn
        },
        success : function(data) {
            $(eval(tmpData)).each(function(index) {
                $("select[name="+selectBoxName+"]").append(
                        "<option value=\""+eval(tmpData)[index].cdNo+"\">"+eval(tmpData)[index].cdNm+"</option>"
                );
            });
            $("#"+selectBoxName+" > option[value ="+value+"]").attr("selected","true");
        },

        error : function(XMLHttpRequest, textStatus, errorThrown) {
              alert("error:"+textStatus+"errorThrown :"+errorThrown);
             }
        });
}

</script>

